@extends('layouts.console_header')

@section('title', '地区用户')

@section('resources')
    @parent
<style>
    .user_list_search{overflow: hidden;margin: 10px 20px;}
    .user_list_search input{float: right;width: 200px;height: 30px;border: 1px solid #000;}
    .user_list_search .user_list_searchbtn{float: right;height: 30px;margin-left: 10px;width: 50px;background-color: #9955c6;color: #fff;border: none;}
    .user_list_pageouter{overflow: hidden;background-color: #fff;}
    .user_list_page{float: right;overflow: hidden;}
    .user_list_page a{float: left;width: 40px;height: 30px;line-height: 30px;text-align: center;}
    .user_list_page .show{background-color: #eee;border: 1px solid #ccc;}
    .display{text-align: center;background-color: #fff;border-collapse:collapse;}
    .display th{padding: 20px 0;}
    .display #tbody_content{border-top: 1px solid #000;border-bottom: 1px solid #000;font-size: 14px;}
    .display #tbody_content tr:nth-child(2n+1){border-bottom: 1px solid #ddd;background-color: #f9f9f9;}
    .display #tbody_content tr:nth-child(2n){border-bottom: 1px solid #ddd;}
    .display #tbody_content tr td{padding: 10px 0;}
    .display #tbody_content tr td:nth-child(1){background-color: #f1f1f1;}

    nav{height: 50px;line-height: 50px;}
    nav a,nav span{margin-left: 20px;}
    nav input{margin-left: 20px;height: 28px;border: 1px solid #000;margin-top: 10px;}
</style>
@endsection

@section('content')
<!--  html内容  -->
<section class="user_list">
	<div style="border-bottom: 2px solid #9955c6;overflow: hidden;">
		<p class="fz_14 account_title fl" style="border: none;"><span style="color: #7f7f7f;"><a href="/console/index">首页</a>>用户版运营></span><span class="co_violet">地区用户</span></p>
		<a href="#"><p class="fr tc back_btn">导出</p></a>
	</div>
    <nav>
        <a class="fl" href="/console/user/region/list?cityid={{$cityid}}&type=today">今日</a>
        <a class="fl" href="/console/user/region/list?cityid={{$cityid}}&type=yesterday">昨日</a>
        <a class="fl" href="/console/user/region/list?cityid={{$cityid}}&type=week">本周</a>
        <a class="fl" href="/console/user/region/list?cityid={{$cityid}}&type=thismonth">本月</a>
        <a class="fl" href="/console/user/region/list?cityid={{$cityid}}&type=lastmonth">上月</a>
        <a class="fl" href="/console/user/region/list?cityid={{$cityid}}&type=all">全部</a>
        <span class="fl">时段选择</span>
        <input class="fl" type="date" name="starttime" value="{{date('Y-m-d', strtotime($starttime))}}" onchange="select_date()">
        <span class="fl">至</span>
        <input class="fl" type="date" name="lasttime" value="{{date('Y-m-d', strtotime($lasttime))}}" onchange="select_date()">
    </nav>
    <p class="user_list_search">
        <span>合计：{{$count}}</span>
        <input class="user_list_searchbtn" type="button" name="submit_search" value="搜索">
        <input type="text" name="search" value="{{$search}}" placeholder="搜索">
    </p>
	<table class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>用户ID</th>
                <th>用户账号</th>
                <th>用户昵称</th>
                <th>地区</th>
                <th>注册来源</th>
                <th>注册时间</th>
                <th>本地订单数</th>
                <th>消费实际金额</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>用户ID</th>
                <th>用户账号</th>
                <th>用户昵称</th>
                <th>地区</th>
                <th>注册来源</th>
                <th>注册时间</th>
                <th>本地订单数</th>
                <th>消费实际金额</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
        </tfoot>
        <tbody id="tbody_content">
            @foreach($lists as $list)
                <tr>
                @if(!isset($i))
                    <td>{{$i=($page-1)*$perpage+1}}</td>
                @else
                    <td>{{++$i}}</td>
                @endif
                    <td>{{$list['mobile']}}</td>
                    <td>{{$list['nickname']}}</td>
                    <td>{{$list['registerarea']}}</td>
                @if($list['shopid'] != 0)
                    <td>商家地推</td>
                 @elseif(isset($list['salesmanid']) && !empty($list['salesmanid']))
                    <td>个人地推</td>
                @else
                    <td>默认</td>
                @endif
                    <td>{{date('Y-m-d H:i', strtotime($list['created_at']))}}</td>
                    <td>{{$list['ordercount']}}</td>
                    <td>{{$list['orderamount']}}</td>
                @if($list['status'] == 1)
                    <td>可用</td>
                @else
                    <td>禁用</td>
                @endif
                    <td>
                        <a style="color: #9955c6;" class="revise" href="/console/user/region/get?cityid={{$cityid}}&userid={{$list['userid']}}">查看</a>
                    </td>
                </tr>
            @endforeach
        </tbody>
    </table>
    <div class="user_list_pageouter">
        <p class="user_list_page">
            <a href="/console/user/region/list?cityid={{$cityid}}&page=1&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">首页</a>
            @if($lastpage <=5)
                @for($i=1; $i<=$lastpage; $i++)
                    @if($page == $i)
                        <a href="/console/user/region/list?cityid={{$cityid}}&page={{$i}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}" class="show">{{$i}}</a>
                    @else
                        <a href="/console/user/region/list?cityid={{$cityid}}&page={{$i}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$i}}</a>
                    @endif
                @endfor
            @else
                @if($page>2)
                    <a href="/console/user/region/list?cityid={{$cityid}}&page={{$page-2}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page-2}}</a>
                @endif
                @if($page>1)
                    <a href="/console/user/region/list?cityid={{$cityid}}&page={{$page-1}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page-1}}</a>
                @endif
                <a href="/console/user/region/list?cityid={{$cityid}}&page={{$page}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}" class="show">{{$page}}</a>
                @if(($page+5)<$lastpage)
                    <a href="/console/user/region/list?cityid={{$cityid}}&page={{$page+1}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page+1}}</a>
                    <a href="/console/user/region/list?cityid={{$cityid}}&page={{$page+2}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page+2}}</a>
                    <a href="/console/user/region/list?cityid={{$cityid}}&page={{$page+3}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page+3}}</a>
                    <a href="/console/user/region/list?cityid={{$cityid}}&page={{$page+4}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page+4}}</a>
                    <a href="">....</a>
                    <a href="/console/user/region/list?cityid={{$cityid}}&page={{$lastpage}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$lastpage}}</a>
                @else
                    @for($i=1; $i<=5;$i++)
                        @if($page+$i<=$lastpage)
                            <a href="/console/user/region/list?cityid={{$cityid}}&page={{$page+$i}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page+$i}}</a>
                        @endif
                    @endfor
                @endif
            @endif
            <a href="/console/user/region/list?cityid={{$cityid}}&page={{$lastpage}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">末页</a>
        </p>
    </div>
</section>
@endsection

@section('scriptResources')
    @parent
<script>
   var cityid = '{{$cityid}}';
   function select_date() {
       var startTime = $("input[name='starttime']").val();
       var lastTime = $("input[name='lasttime']").val();
       if(!startTime || !lastTime) {
           alert('请选择开始时间和结束时间'); return;
       }
       window.location.href="/console/user/region/list?cityid=" + cityid+"&starttime="+startTime+"&lasttime="+lastTime;
   }
   $("input[name='submit_search']").click(function() {
      var search = $("input[name='search']").val();
      window.location.href="/console/user/region/list?cityid=" + cityid+"&search="+search;
   })

</script>
@endsection